<%-- 
    Document   : reunion
    Created on : 07-07-2012, 05:38:44 PM
    Author     : Alex
--%>

<%@include file="/include/header.jsp" %>
<script>
    
    function EliminarReunion(){
        $( "#dialog:ui-dialog" ).dialog( "destroy" );
    
        $( "#dialog-confirm" ).dialog({
            resizable: false,
            height: 'auto',
            width: 490,
            modal: true,
            buttons: {
                Eliminar: function() {
                    $( this ).dialog( "close" );
                    var form = document.getElementById("reunionForm");
                    form.cmd.value = "EliminarReunion";
                    form.submit();
                },
                Cancelar: function() {
                    $( this ).dialog( "close" );
                }
            }
        });
        
        
    }
    
    function crearAgenda(){
        //var url = getBaseURL();
        //url = url + "AgendaReunion.jsa?cmd=init&codR="+document.getElementById("idReunion").value;
        var url = "./AgendaReunion.jsa?cmd=init&codR="+document.getElementById("idReunion").value;
        window.open(url, "reuWin", "HEIGHT=600, WIDTH=575, MODAL=YES, scrollBars=YES");      
    }
    
    /* Aqui validaciones javascript, si las hubiere */
    function buscarReunion(){
        var form = document.getElementById("reunionForm");
        var url = form.action + "?cmd=initBusqueda";
	window.open(url, "reuWin", "HEIGHT=600, WIDTH=575, MODAL=YES, scrollBars=YES");
    }
    
    function clean(){
        var form = document.getElementById("reunionForm");
        form.reset();
        form.cmd.value = "init";
        form.submit();
    }
    
    function validateForm(){
        var reuForm = document.getElementById("reunionForm");
        if(reuForm.tema.value.trim() == ""){
            $( "#dialog:ui-dialog" ).dialog( "destroy" );
            $( "#dialog-message" ).dialog({minHeight: 70, height: 180, modal: true, buttons: {Ok: function() {$( this ).dialog( "close" );}}});
            return false;
        }
        if(reuForm.ponente.value.trim() == ""){
            $( "#dialog:ui-dialog" ).dialog( "destroy" );
            $( "#dialog-message2" ).dialog({minHeight: 70, height: 180, modal: true, buttons: {Ok: function() {$( this ).dialog( "close" );}}});
            return false;
        }
        if(reuForm.horafechaReunion.value.trim() == ""){
            $( "#dialog:ui-dialog" ).dialog( "destroy" );
            $( "#dialog-message3" ).dialog({minHeight: 70, height: 180, modal: true, buttons: {Ok: function() {$( this ).dialog( "close" );}}});
            return false;
        }
        if(reuForm.lugar.value.trim() == ""){
            $( "#dialog:ui-dialog" ).dialog( "destroy" );
            $( "#dialog-message4" ).dialog({minHeight: 70, height: 180, modal: true, buttons: {Ok: function() {$( this ).dialog( "close" );}}});
            return false;
        }
        if(reuForm.comentarios.value.toString().length > 1500){
            $( "#dialog:ui-dialog" ).dialog( "destroy" );
            $( "#dialog-message5" ).dialog({minHeight: 70, height: 180, modal: true, buttons: {Ok: function() {$( this ).dialog( "close" );}}});
            return false;
        }
        return true;
    }
    
    function save(){
        var reuForm = document.getElementById("reunionForm");
        if(validateForm() == true){
            reuForm.submit();
        }
    }
    
    /* Fin validaciones javascript */
    
    
    $(document).ready(function () {
        $.datepicker.setDefaults($.datepicker.regional['es']);
    });
    
    $(function(){
        $('#datepicker').datetimepicker({
            dateFormat: 'dd/mm/yy',
            timeFormat: 'hh:mm',
            timeText: 'Hora:',
            hourText: 'horas:',
            minuteText: 'minutos:',
            secondText: 'segundos:',
            currentText: 'Hoy',
            closeText: 'Listo',
            minDate: new Date()
        });
    });


</script>
<div class="content">
    <html:form action="/Reunion" styleId="reunionForm" onsubmit="return validateForm()">
        <logic:equal name="save" value="new">
            <html:hidden property="cmd" value="AgregarReunion" />
        </logic:equal>
        <logic:notEqual name="save" value="new">
            <html:hidden property="cmd" value="ModificarReunion" />
        </logic:notEqual>
        <table class="form">
            <caption class="titleSeg">Mantenimiento de Reuniones</caption>
            <logic:equal name="save" value="new">
                <html:hidden property="idReunion" styleClass="tinput125" styleId="idReunion" />
            </logic:equal>
            <logic:notEqual name="save" value="new">
                <html:hidden property="idReunion" styleClass="tinput125" styleId="idReunion" />
            </logic:notEqual>
            <tr class="campos">
                <td class="label">Tema:&nbsp;&nbsp;</td>
                <td class="control"><html:text property="tema" styleClass="tinput404" /></td>
            </tr>
            <tr class="campos">
                <td class="label">Ponente:&nbsp;&nbsp;</td>
                <td class="control"><html:text property="ponente" styleClass="tinput404" /></td>
            </tr>
            <tr class="campos">
                <td class="label">Fecha y Hora:&nbsp;&nbsp;</td>
                <td class="control"><html:text property="horafechaReunion" styleId="datepicker" /></td>
            </tr>
            <tr class="campos">
                <td class="label">Lugar:&nbsp;&nbsp;</td>
                <td class="control"><html:text property="lugar" styleClass="tinput404" /></td>
            </tr>
            <tr class="campos">
                <td class="label">Comentarios:&nbsp;&nbsp;</td>
                <td class="control"><html:textarea cols="52" rows="10" property="comentarios" /></td>
            </tr>
            <logic:present name="msg">
            <tr>
                <td colspan="2" class="success">
                    <html:img src="./images/ok.png" />&nbsp;
                    <html:messages id="mensaje" name="msg">
                        <bean:write name="mensaje" />
                    </html:messages>
                </td>
            </tr>
            </logic:present>
            <logic:present name="errors">
            <tr>
                <td colspan="2" class="errors">
                    <html:img src="./images/error.png" />&nbsp;<html:errors name="errors" />
                </td>
            </tr>
            </logic:present>
            <tr>
                <td colspan="2"><br /></td>
            </tr>
            <tr class="botones">
                <td colspan="2">
                    <div style="float: left">
                        &nbsp;&nbsp;&nbsp;
                        <html:button property="guardarReu" onclick="save();" value="Guardar" styleClass="button" />
                        <html:reset value="Limpiar" styleClass="button" />
                        <logic:notEqual name="save" value="new">
                            <html:button value="Eliminar" property="agenda" styleClass="button" onclick="EliminarReunion();" />
                        </logic:notEqual>
                    </div>
                    <div style="float: right">
                        <html:button value="Realizar B&uacute;squeda" property="buscar" styleClass="button" onclick="buscarReunion();" />
                    </div>
                </td>
            </tr>
            <logic:notEqual name="save" value="new">
            <tr>
                <td colspan="2">
                    <div style="float: right">
                    <html:button value="Editar Agenda" property="agenda" styleClass="button" onclick="crearAgenda();" />
                    </div>
                </td>
            </tr>
            </logic:notEqual>
        </table>
    </html:form>
    
    
    <!-- DIVS DE MENSAJES DE VALIDACIONES -->
    <div style="height: 75px; display: none" id="dialog-confirm" title="&iquest;Eliminar Reuni&oacute;n?">
        <table style="font-size: 13px;">
            <tr>
                <td><img src="./images/Warning.png" alt="Atenci&oacute;n" /></td>
                <td style="text-align: justify">Si elimina la reuni&oacute;n, se eliminar&aacute;n tambi&eacute;n su agenda y el registro de los asistentes. &iquest;Est&aacute; seguro que desea continuar?</td>
            </tr>
        </table>
    </div>
    
    <div id="dialog-message" style="display: none" title="Advertencia">
	<p>
            <span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
            El tema es obligatorio
	</p>
    </div>
    
    <div id="dialog-message2" style="display: none" title="Advertencia">
	<p>
            <span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
            El ponente es obligatorio
	</p>
    </div>
    
    <div id="dialog-message3" style="display: none" title="Advertencia">
	<p>
            <span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
            La fecha y hora son obligatorias
	</p>
    </div>
    
    <div id="dialog-message4" style="display: none" title="Advertencia">
	<p>
            <span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
            El lugar es obligatorio
	</p>
    </div>
    
    <div id="dialog-message5" style="display: none" title="Advertencia">
	<p>
            <span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
            El comentario es demasiado largo. Se admite un m&aacute;ximo de 1500 caracteres (contando los espacios)
	</p>
    </div>
    <!-- ******************************** -->
    
</div>
<%@include file="/include/footer.jsp" %>
